home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group01a.txt
/
000011_icon-group-sender _Wed May 17 07:43:13 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2002-01-03
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id HAA00794
for icon-group-addresses; Wed, 17 May 2000 07:42:44 -0700 (MST)
Message-Id: <200005171442.HAA00794@baskerville.CS.Arizona.EDU>
From: "Frank J. Lhota" <NOSPAM.Frank.Lhota@lexma.meitech.com>
X-Newsgroups: comp.lang.icon
Subject: Re: Reversible assignment really reversible ?
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Date: Wed, 17 May 2000 09:21:29 -0000
X-Trace: client 958569712 38.163.203.81 (Wed, 17 May 2000 09:21:52 EDT)
To: icon-group@optima.CS.Arizona.EDU
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Content-Length: 1452
"F.G. van DORP" <F.G.van.Dorp@digimedia.nl> wrote in message
news:h553is4c3ulev333pul872qcr7e5uvubih@4ax.com...
> BTW,
> #-------------------------------------
> procedure revass(a,b)
> local c; c:=a
> suspend (a:=b|(a:=c, &fail))
> #-------------------------------------
> doesn't seem to work in the 8queens example, neither
> does MYREVASS() (without the &FAIL),
> but that was no big surprise.
There may be a misunderstanding here. In Icon, all procedure parameters are
passed by value, not by reference. When the procedure revass is called, a
and b are assigned the values of the first and second actual parameters (or
&null if these parameters are not specified). If the statements in revass
changes in a and b, these changes are NOT copied back to the actual
parameters. If we were to execute the following Icon code:
c := 3
revass( c, 4 )
the value of c would not be affected. The revass function would assign 4 to
the local variable a, but that would have no impact on c.
The situation is similar in the C language. The C function
int Assign( int a, int b )
{
return ( a = b );
}
does NOT simulate C integer assignment, since the assignment statement ( a =
b ) only changes the local variable a.
If you want to simulate reversible assignment, you need a more sophisticated
approach. Icon structures such as lists and records use pointer semantics,
and can be used to get the effect of pass by reference.